home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 26
/
Cream of the Crop 26.iso
/
program
/
p063b9s.zip
/
TOKENRES.PAS
< prev
Wrap
Pascal/Delphi Source File
|
1993-09-26
|
2KB
|
75 lines
USES OpRoot, OpString;
PROCEDURE ParseFile;
VAR
f : Text;
Line : LongInt;
StrDict : StringDictPtr;
Lib : OpLibrary;
ResName, s, Token : String;
l : LongInt;
BEGIN
Assign(f, ParamStr(1));
Reset(f);
IF IOResult=0 THEN
BEGIN
Line:=1; StrDict:=NIL;
Lib.Init('PORTAL.RES', SOpen, 10240, 'POP-RES');
(* Lib.Create('TEST.RES', {SCreate,} 4096, 'POP-RES', 32);*)
Lib.RegisterHier(StringDictStream);
WHILE Not EoF(f) DO
BEGIN
Write(Line,#13);
ReadLn(f, s);
IF (Length(s)>0) AND (Copy(s, 1, 1)<>';') THEN
BEGIN
{ s:=StUpCase(s);}
IF Copy(s, 1, 9)='#KEYWORDS' THEN
BEGIN
IF StrDict<>NIL THEN
BEGIN
Lib.PutEntry(ResName, StrDict^);
Dispose(StrDict, Done);
END;
New(StrDict, Init);
Delete(s,1,9); s:=Trim(s);
IF Str2Long(s, l) THEN
BEGIN
ResName:='TOK'+LongIntForm('@@@',l);
END;
END ELSE
BEGIN
Token:=Copy(s, 1, Pos(' ',s)-1);
Delete(s, 1, Length(Token)); s:=Trim(s);
IF Str2Long(s, l) THEN StrDict^.Add(Token, l);
{ Begin
if not strdict^.member(Token, l) then
else
Writeln('Duplicate : ',Token,' # ',l);
end; }
END;
END;
Inc(Line);
END;
IF StrDict<>NIL THEN
BEGIN
Lib.PutEntry(ResName, StrDict^);
Dispose(StrDict, Done);
END;
WriteLn;
Close(f);
END ELSE
WriteLn('Can''t open: ',ParamStr(1));
END;
BEGIN
WriteLn('Token file parser for Portal of Power v');
WriteLn('(c) Copyright 1993 by The Portal Team');
IF ParamCount=1 THEN
ParseFile
ELSE
WriteLn(' USAGE: TokenRes FileName');
WriteLn;
END.